#include <stdio.h>
#include <stdlib.h>

int
digit_sum(int n)
{
	int sum = 0;

	while (n > 0) {
		sum += n % 10;
		n /= 10;
	}

	return sum;
}

int
main(void)
{
	int n, k;
	int i = 1, count = 0;

	scanf("%d%d", &n, &k);

	if (n < 0) {
		while (i >= n) {
			if (digit_sum(abs(i)) % k == 0) {
				count++;
			}
			i--;
		}
	} else if (n > 0) {
		while (i <= n) {
			if (digit_sum(i) % k == 0) {
				count++;
			}
			i++;
		}
	} else {
		count = 1 + (k == 1 ? 1 : 0);
	}

	printf("%d\n", count);

	return 0;
}
